package cn.iocoder.yudao.module.crossborder.compliance.api;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crossborder.compliance.api.dto.ComplianceCheckDTO;
import cn.iocoder.yudao.module.crossborder.compliance.service.ComplianceService;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 合规管理 API 接口实现类
 *
 * @author LHL
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class ComplianceApiImpl implements ComplianceApi {

    @Resource
    private ComplianceService complianceService;

    @Override
    public CommonResult<ComplianceCheckDTO> getComplianceCheck(Long id) {
        ComplianceCheckDTO complianceCheck = complianceService.getComplianceCheck(id);
        return success(complianceCheck);
    }

    @Override
    public CommonResult<List<ComplianceCheckDTO>> getComplianceCheckList(List<Long> ids) {
        List<ComplianceCheckDTO> complianceChecks = complianceService.getComplianceCheckList(ids);
        return success(complianceChecks);
    }

    @Override
    public CommonResult<Long> createComplianceCheck(ComplianceCheckDTO complianceCheck) {
        Long id = complianceService.createComplianceCheck(complianceCheck);
        return success(id);
    }

    @Override
    public CommonResult<Boolean> validateProductCompliance(Long productId, String countryCode) {
        Boolean isCompliant = complianceService.validateProductCompliance(productId, countryCode);
        return success(isCompliant);
    }

}
